import { validationResult } from 'express-validator';
import { ResponseUtil } from '../utils/response';

export const validateMiddleware = (req: any, res: any, next: any) => {
  const errors = validationResult(req);
  if (!errors.isEmpty()) {
    return ResponseUtil.error(res, errors.array()[0].msg);
  }
  next();
};
